<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue指令</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <style>
        .ok{
           color:green;
        }
        .error{
            color:red;
        }
    </style>
</head>
<body>
<div id="d1">
    <!--
        将数据仓库中的数据绑定到指定的属性中
    -->
    <!--<img v-bind:src="url" alt="图片加载失败">-->
    <!-- 可以将v-bind省略 -->
    <img :src="url" alt="图片加载失败" :width="width"><br/>
    <!--
        {key:value}
        value是一个boolean的数据
        当值为true时,选择对应key的样式
    -->
    <input type="text" :class="{ok:flag,error:!flag}" @input="check($event.target.value)"><br/>
    <input type="text" v-model="name"/><br/>
    <input type="radio" v-model="gender" value="man">男
    <input type="radio" v-model="gender" value="woman">女<br/>
    <input type="checkbox" v-model="hobbies" value="eat">吃饭
    <input type="checkbox" v-model="hobbies" value="sleep">睡觉
    <input type="checkbox" v-model="hobbies" value="dadoudou">打豆豆<br/>
    <select v-model="edu">
        <option value="-1">请选择</option>
        <option value="1">大专</option>
        <option value="2">本科</option>
        <option value="3">研究生</option>
    </select>
</div>
<script>
    new Vue({
        el: "#d1",
        data:{
            url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F4k%2Fs%2F02%2F2109242306111155-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1656569947&t=c503852c5343ad30bbdaba06251d5c8f",
            width: "200px",
            flag:true,
            name:"admin",
            gender:"男",
            hobbies:["eat"],
            edu:1
        },
        methods:{
            check(value){
                this.flag = value.length >= 6 && value.length <= 10
            }
        }
    })
</script>
</body>
</html>